home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Misc / IconBounce / Source / Animator.h < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.9 KB  |  91 lines

  1.  
  2. /* Not generated by Interface Builder */
  3.  
  4. /*
  5.  * This is an Animator class which is sort of different from the
  6.  * Animator found in the Stopwatch program.  It is a bit more standalone,
  7.  * as I wanted to be able to create objects which only animated if they
  8.  * were the target of an Animator, or if they had an Animator as an outlet.
  9.  * (The Animator class allows the Animator to be either an outlet, or to
  10.  * have a target, and animate in much the same way.)  See the accompanying
  11.  * documentation for more help (Animator.wn).
  12.  */
  13.  
  14. #import <objc/Object.h>
  15. #import <appkit/Application.h>
  16.  
  17. @interface Animator:Object
  18. {
  19.     id target;            // The thing we are animating.
  20.     DPSTimedEntry te;        // the timed entry we are using.
  21.     BOOL running;        // YES if we are running.
  22.     float timing;        // the current timing we are using.
  23.     float threshold;        // the threshold we are running at.
  24.     SEL action;            // message to send to target.
  25.     
  26.     double startTime;        // when we started.
  27.     double elapsed;        // time between current call and the original.
  28. }
  29.  
  30. + new;                // create a new Animator.
  31.  
  32. // These routines allow the user to set up the default values for Animator
  33. // objects.  Using these factory methods, a subclass may easily change the
  34. // Animator's actions by calling these methods in an initialize factory
  35. // method.
  36. + setDefaultTiming:(float)dtiming;
  37. + setDefaultThreshold:(float)dthreshold;
  38. + setDefaultAction:(SEL)daction;
  39. + setDefaultRunning:(BOOL)state;
  40.  
  41. - free;                // free the Animator up.
  42.  
  43. // These routines set up the animator according to the user's desires.
  44. - setTarget:anObject;        // calls setAnimator if anObject implements.
  45. - target;
  46. - setTiming:(float)timing;
  47. -(float)timing;
  48. - setThreshold:(float)threshold;
  49. -(float)threshold;
  50. - setAction:(SEL)aSelector;
  51. -(SEL)action;
  52. - setRunning:(BOOL)state;
  53. -(BOOL)running;
  54. -(double)doubleValue;        // return the amount of time since last call.
  55. -(float)floatValue;        // return as a float.
  56. -(int)intValue;
  57. - resetValue:(double)value;    // reset the start time to value.
  58. - resetValue;            // reset start time to now.
  59.  
  60. // sendAction:to: sends theAction with parameter self to theTarget.  If
  61. // theAction is NULL, or theTarget is nil, nothing is sent.  sendAction
  62. // sends the animator's action to its target.
  63. - sendAction:(SEL)theAction to:theTarget;
  64. - sendAction;
  65.  
  66. // These are to be hooked up to various user interface objects, such as
  67. // buttons and sliders.
  68. - start:sender;            // start the Animator.
  69. - stop:sender;            // stop the Animator.
  70. - toggleRun:sender;        // toggle the Animator's state.
  71. - takeTimingFrom:sender;    // to hook up a slider.
  72. - takeRunningFrom:sender;    // set state by sender.
  73.  
  74. // These routines are for reading and writing the animator.
  75. - copy;
  76. - awake;
  77. - write:(NXTypedStream *)stream;
  78. - read:(NXTypedStream *)stream;
  79.  
  80. @end
  81.  
  82. // This is stuff which the target may wish to implement.  The Animator class
  83. // checks to see that the target can run them before calling it.
  84. @interface AnimatorTarget:Object
  85. {
  86. }
  87.  
  88. - setAnimator:sender;
  89.  
  90. @end
  91.